from selenium import webdriver
from selenium.webdriver.common.by import By
from time import sleep

driver = webdriver.Edge()
driver.get('http://10.59.9.12:7001/')
driver.maximize_window()
sleep(2)
# 第一步 点击登录超链接
driver.find_element(By.LINK_TEXT,'登录').click()
sleep(1)
# 第二步 输入账号
driver.find_element(By.NAME,'username').send_keys('18238680385')
sleep(1)
# 第三步 输入密码
driver.find_element(By.CSS_SELECTOR,'#theForm > div:nth-child(2) > span.register-input > input').send_keys('123456')
sleep(1)
# 强等输入验证码
sleep(6)
# 第四步 点击登录按钮
driver.find_element(By.XPATH,'//a[contains(@class,"finish-btn")]').click()
sleep(5)
# 第五步 点击秒杀
driver.find_element(By.XPATH,'/html/body/div[3]/div[2]/ul/li[4]/a').click()
sleep(1)
# 第六步 选择商品
driver.find_element(By.XPATH,'/html/body/div[5]/div[2]/div[2]/div[1]/ul/li[1]/div[1]/span/a/img').click()
sleep(1)
# 第七步 点击立即购买
driver.find_element(By.ID,'buy-cart').click()
sleep(1)
# 第八步 点击下一步
driver.find_element(By.ID,'order-button').click()
sleep(5)
